package com.company.project.web.system.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.company.project.common.enums.RestCodeEnum;
import com.company.project.common.utils.JsonUtils;
import com.company.project.common.utils.RestUtil;
import com.company.project.common.pojo.Rest;
import com.company.project.web.system.pojo.building_room.BuildingRoom;
import com.company.project.web.system.pojo.building_room.BuildingRoomSelectVO;
import com.company.project.web.system.service.BuildingRoomService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 任建波
 * @since 2019-09-09
 */
@Controller
@RequestMapping("/system/building-room")
public class BuildingRoomController {

    @Autowired
    private BuildingRoomService buildingRoomService;

    @ApiOperation(value = "获取房间列表")
    @ApiImplicitParams({
        @ApiImplicitParam(paramType = "header", name = "xxxToken", value = "请求头token", required = true, dataType = "String"),
    })
    @RequestMapping(value = "getBuildingRoomList", method = RequestMethod.GET)
    @ResponseBody
    public Rest<BuildingRoomSelectVO> getBuildingRoomList() {
        QueryWrapper<BuildingRoom> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("isdelete", 0);
        List<BuildingRoom> buildingRoomList = buildingRoomService.list(queryWrapper);

        List<BuildingRoomSelectVO> buildingRoomSelectVOList = JsonUtils.jsonToList(buildingRoomList, BuildingRoomSelectVO.class);

        return RestUtil.rest(RestCodeEnum.CODE_200.getCode(), RestCodeEnum.CODE_200.getDesc(), buildingRoomSelectVOList);
    }

}

